home *** CD-ROM | disk | FTP | other *** search
- Path: news.une.edu.au!usenet
- From: Jon Snow <jwilkie@turing.une.edu.au>
- Newsgroups: comp.lang.c++
- Subject: Re: How to delete array of pointers?
- Date: 11 Feb 1996 22:53:32 GMT
- Organization: University of New England
- Message-ID: <4fls1c$1n1@grivel.une.edu.au>
- References: <4fgvsu$5q4@eng_ser1.erg.cuhk.hk>
- NNTP-Posting-Host: turing.une.edu.au
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 1.1N (X11; I; OSF1 V2.0 alpha)
- X-URL: news:4fgvsu$5q4@eng_ser1.erg.cuhk.hk
-
- ywleung@cs.cuhk.hk (Marty McFly) wrote:
- >If I write the following code in a function:
- >
- > int** ptr;
- > ptr = new int*[1000];
- >
- >Is this code means allocating 1000 integer pointers which is pointed by ptr?
- >And then somehow I assign integer variable to ptr[0], ptr[1], ... and so on.
- >So at the end of the function, how can I reclaim just those pointers? The key
- >point is that those integer variable assigned to the pointers should not be
- >deleted.
- >
- >Regards,
- >Marty McFly.
-
- I assume since you don't want to delete the pointers assigned a value that
- you wish to free up only the memory in the unused pointers. Try using the
- C functions calloc and realloc. If you don't like using C then create your
- own C++ memory class.
- Hope this is what your after.
- Regards Jon.
-
- Jon Snow <jwilkie@turing.une.edu.au>
-
-